<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>转班详情</title>
<link rel="stylesheet" href="layui/css/layui.css" media="all">
</head>
<body>
	<table class="layui-hide" id="zhuanbanetail" lay-filter="zhuanbanetail"></table>
	
	<script type="text/html" id="barDemo">
 		 <a class="layui-btn layui-btn-xs" lay-event="edit">申请取消</a>
	</script>
	<!-- js引入 -->
	<script src="js/jquery.js"></script>
	<script src="layui/layui.js" charset="utf-8"></script>
</body>
<script type="text/javascript">
//数据表格
layui.use(['table','form','layedit', 'laydate'], function(){
	var table = layui.table;
	  var form = layui.form
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate;
	table.render({
		elem : '#zhuanbanetail',
		url : 'getchangeclazz',
		page : true,
		cols : [ [ {
			field : 'user_id',
			width : 150,
			title : '姓名',
			templet : function(row) {
				return row.user_id.user_name;
			}
		},{
			field : 'oldclassid',
			width : 150,
			title : '原来的班级',
			templet : function(row) {
				return row.oldclassid.clazz_name;
			}
		} ,{
			field : 'newclassid',
			width : 150,
			title : '想转入的班级',
			templet : function(row) {
				return row.newclassid.clazz_name;
			}
		}, {
			field : 's_state',
			width : 300,
			title : '状态',
			templet : function(row) {
				if(row.s_state==0){
					return "已提交给老师请耐心等待处理";
				}else if(row.s_state==1){
					return "通过";
				}else if(row.s_state==2){
					return "不通过";
				}
				return "已取消";
			}
		}, {
			field : 'caozuo',
			width : 100,
			title : '操作',
			toolbar:"#barDemo"
		}] ]
	});
	//监听工具条
	  table.on('tool(zhuanbanetail)', function(obj){
	    var data = obj.data;
	    var s_id=data.s_id
	   if(obj.event === 'edit'){
	      layer.confirm('真的要取消么', function(index){
	    	 if(data.s_state==0){
	    		 $.ajax({
		    		  url:"editChangeclazz",
		    			type:"post",
		    			data:{
							id:s_id
						},
		    			success:function(data){
		    				if(data.code==0){
		    					location.href="changeclazzdetail";
		    				}else{
		    					 layer.msg("遇到未知错误操作失败！")
		    				}
		    			}
		    	  });
	    	 }else{
	    		 layer.msg("已完成或以是取消状态！")
	    	 }
	        layer.close(index);
	      });
	    } 
	  });
});
</script>
</html>